package com.bestescortbedsystem.controller.qianduan;

import com.bestescortbedsystem.entity.SesUserIdentity;
import com.bestescortbedsystem.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ClassName: UserController
 * Package: com.bestescortbedsystem.controller.qianduan
 *
 * @author: guanzepeng
 * @Date: 2021/2/25 12:12 星期四
 * @Description: 用户操作Controller
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api(tags = "用户操作的controller")
public class UserController {

	@Resource
	private UserService userService;

	/**
	 * 执行删除订单操作,只有已完成的订单才可以成功删除
	 * @param userorderId 传入订单编号
	 * @return 返回Boolean
	 */
	@ApiOperation(value = "执行删除订单操作,只有已完成的订单才可以成功删除", response = Boolean.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userorderId", value = "订单ID", required = true, dataTypeClass = Integer.class)
	})
	@DeleteMapping("/deleteorder")
	public Boolean deleteOrder(Integer userorderId){
		Boolean b = userService.deleteOrder(userorderId);
		return b;
	}

	/**
	 * 根据传入的对象修改真实姓名和银行卡号
	 * @param sesUserIdentity 传入对象
	 * @return 返回Boolean
	 */
	@PostMapping("/updateidentity")
	@ApiOperation(value = "根据传入的对象修改真实姓名和银行卡号", response = Boolean.class)
	public Boolean updateIdentity(SesUserIdentity sesUserIdentity) {
		Boolean aBoolean = userService.updateIdentity(sesUserIdentity);
		return aBoolean;
	}

	/**
	 * 强制结算功能
	 * @param userorderId 传入订单ID
	 * @return 返回Boolean
	 */
	@PostMapping("/updateuserorder")
	@ApiOperation(value = "强制结算功能", response = Boolean.class)
	@ApiImplicitParam(name = "userorderId", value = "传入订单ID", required = true, dataTypeClass = Long.class)
	public Boolean updateUserOrder(Long userorderId) {
		Boolean b = userService.updateUserOrder(userorderId);
		return b;
	}
}
